/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package controller;

import BO.Iter.MonHocBO;
import TableModel.Monhoc;
import java.util.List;
import java.util.Map;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;



/**
 *
 * @author vt
 */
public class MonHocController {
    public static final String TAG ="AT MON_HOC_CONTROLLER";
    private MonHocBO mhBO;
    String strId;
    Monhoc bean;
    public void init(){
         
    }
    public Monhoc getBean() {
        return bean;
    }

    public void setBean(Monhoc bean) {
        this.bean = bean;
    }

    public String getStrId() {
        return strId;
    }

    public void setStrId(String strId) {
        this.strId = strId;
    }
    
    
    public MonHocBO getMhBO() {
        return mhBO;
    }

    public void setMhBO(MonHocBO mhBO) {
        this.mhBO = mhBO;
    }
    
    public List<Monhoc> getAll(){
        System.out.println("name of mhBO: " + mhBO.toString());
       return  mhBO.listAllMonHoc();
    }
    public String monhocId(){
        System.out.println("name of Id: ");
        System.out.println(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id").toString());
           return (String) FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("id");
           
    }
    
    public String actionEdit() {
        getMonHocById();
        return "mhedit";
    }
    public String actionNew(){
        return "mhadd";
    }
    public void actionListenerEdit(ActionEvent  event){
            // getMonHocById();
    }
    public String movePageShow(Monhoc a){
               mhBO.edit(a);
           return "mhshow";
    }
    public void delete (Monhoc a){
        try{
            mhBO.delete(a);
        }catch(Exception e){
            
        }
    }
    public void getMonHocById(){
      String id =  monhocId();
       bean  = mhBO.findById(id);
    }
}
